package org.example.seata.bs.order.controller;

import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.example.seata.bs.api.dto.order.OrderDto;
import org.example.seata.bs.api.vo.order.OrderVo;
import org.example.seata.bs.order.service.OrderEnhanceService;
import org.example.seata.common.core.util.ApiResp;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

/**
 * @author hzq
 * @date 2021/11/17 15:13
 */
@RestController
@RequestMapping("/order")
@AllArgsConstructor
public class OrderController {

    private final OrderEnhanceService orderEnhanceService;

    @PostMapping
    @ApiOperation("创建订单")
    public ApiResp<OrderVo> create(@Valid @RequestBody OrderDto dto) {
        return orderEnhanceService.create(dto);
    }

    @GetMapping("/pendingOrder")
    @ApiOperation("待支付订单列表")
    public ApiResp<List<OrderVo>> pendingOrder() {
        return orderEnhanceService.pendingOrder();
    }

    @GetMapping("/allOrder")
    @ApiOperation("全部订单列表")
    public ApiResp<List<OrderVo>> allOrder() {
        return orderEnhanceService.allOrder();
    }

}
